﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ERPStudio;
using System.Data.SqlClient;

namespace ResUma
{
    public partial class GrilaFrm : FrmRezumat
    {
        protected int _IDTipSpor = -1;
        public GrilaFrm(ModuleClass mc,int idtipspor):base(mc)
        {
            _IDTipSpor = idtipspor;
            InitializeComponent();
            workConnString = "ESRPConnectionString";
            ActiveControl = grileDataGridView;
        }

        private void GrilaFrm_Load(object sender, EventArgs e)
        {
            SqlConnection con = DeschideConexiune(workConnString);
            this.tipSporTableAdapter.Connection = con;
            this.tipSporTableAdapter.FillByFormat(this.eSRPDataSet.TipSpor, "G");
  
            this.grileTableAdapter.Connection = con;
            if (_IDTipSpor == -1)
                this.grileTableAdapter.Fill(this.eSRPDataSet.Grile);
            else
            {
                this.grileTableAdapter.FillByIDSpor(this.eSRPDataSet.Grile, _IDTipSpor);
                IDTipSporColumn.Visible = false;
                eSRPDataSet.Grile.IDTipSporColumn.DefaultValue = _IDTipSpor;
            }
            InchideConexiune(con);

            AddBindingSource(grileBindingSource);
            listTableAdaptor.Add(grileTableAdapter.Adapter);
            HandleSalvare += Salvare;
        }
    }
}
